package com.p2p.front.web.controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.p2p.base.annotation.LoginNeedless;
import com.p2p.base.model.BaseUser;
import com.p2p.base.web.controller.BaseController;
import com.p2p.front.service.ApplyLoanService;
import com.p2p.front.web.form.LoanApplyForm;

@Controller
public class LoanApplyController extends BaseController {
	
	@Resource
	private ApplyLoanService applyLoanService;
	
	@LoginNeedless
	@RequestMapping("/loan/apply")
	public String apply(){
		return "loan/apply";
	}
	
	@LoginNeedless
	@RequestMapping("/loan/saveApplyInfo")
	public String saveApplyInfo(LoanApplyForm form) {
		BaseUser user = getCurrentUser();
		if(user!=null){
			String userId= user.getId();
			form.setUserId(userId);
		}
		
		applyLoanService.saveLoanApplyInfo(form);
		return "loan/applysuccess";
	}

}
